package com.ruoyi.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.entity.SysUserGroup;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import java.util.List;

/**
 * 【请填写功能名称】Mapper接口
 * @date 2023-03-16
 */
@Repository
public interface SysUserGroupMapper extends BaseMapper<SysUserGroup>
{
    /**
     * 查询【请填写功能名称】列表
     * 
     * @param sysUserGroup 【请填写功能名称】
     * @return 【请填写功能名称】集合
     */
    public List<SysUserGroup> selectSysUserGroupList(SysUserGroup sysUserGroup);

    @Select("SELECT t.user_id,t.nick_name as user_name,t.open_id FROM `sys_user` t WHERE t.user_id = #{userId} or FIND_IN_SET(t.user_id,(SELECT GROUP_CONCAT(g.users_id) AS users_id FROM `sys_user_group` g WHERE FIND_IN_SET(#{userId},users_id) != 0))")
    List<SysUser> getGroupUserList(@Param("userId") Long userId);
}
